//
// Interface.inl
// Your copyright notice
//

// Set default to be first implementation found by resolver
_LIT8(KDefaultImplementation,"*");

inline CPluginInterface::CPluginInterface()
{
}

inline CPluginInterface::~CPluginInterface()
{
	// Destroy any instance variables and then
	// inform the framework that this specific 
	// instance of the interface has been destroyed.
	REComSession::DestroyedImplementation(iDtor_ID_Key);
}

inline CPluginInterface* CPluginInterface::NewL()
{
	// Set up the interface find for the default resolver.
	TEComResolverParams resolverParams;
	resolverParams.SetDataType(KDefaultImplementation());
	resolverParams.SetWildcardMatch(ETrue);		// Allow wildcard matching

	// Set up some empty initialisation parameters
	TPluginInterfaceInitParams initParams;

	const TUid KPluginResolverUid = {0x10001AD0};
	return REINTERPRET_CAST(CPluginInterface*, 
		REComSession::CreateImplementationL(KCPluginInterfaceUid, 
		_FOFF(CPluginInterface,iDtor_ID_Key),
		&initParams,
		resolverParams,
		KPluginResolverUid));
}

inline CPluginInterface* CPluginInterface::NewL(const TDesC8& aMatchString)
{
	// Set up the interface find for the default resolver.
	TEComResolverParams resolverParams;
	resolverParams.SetDataType(aMatchString);
	resolverParams.SetWildcardMatch(ETrue);		// Allow wildcard matching

	// Set up some empty initialisation parameters
	TPluginInterfaceInitParams initParams;

	return REINTERPRET_CAST(CPluginInterface*, 
		REComSession::CreateImplementationL(KCPluginInterfaceUid, 
		_FOFF(CPluginInterface,iDtor_ID_Key), 
		&initParams,
		resolverParams));
}

inline CPluginInterface* CPluginInterface::NewL(const TDesC8& aMatchString, TPluginInterfaceInitParams& aParams)
{
	// Set up the interface find for the default resolver.
	TEComResolverParams resolverParams;
	resolverParams.SetDataType(aMatchString);
	resolverParams.SetWildcardMatch(ETrue);		// Allow wildcard matching

	// The CreateImplementationL method will return
	// the created item.
	return REINTERPRET_CAST(CPluginInterface*, REComSession::CreateImplementationL(KCPluginInterfaceUid,
		_FOFF(CPluginInterface,iDtor_ID_Key),
		&aParams,
		resolverParams));
}

inline void CPluginInterface::ListAllImplementationsL(RImplInfoPtrArray& aImplInfoArray)
{
	REComSession::ListImplementationsL(KCPluginInterfaceUid, aImplInfoArray);
}
